﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Beacon.SPC
{


    /// <summary>
    /// For user to create rules.
    /// </summary>
    public class SpcRuleFactory
    {
        public static ISpcRule CreateRule(SpcControlLimit limit, SpcRuleDefinition define)
        {
            return CreateRule(define.Type, limit, define.Side);
        }

        public static ISpcRule CreateRule(SpcRules rule, SpcControlLimit limit, SpcControlSide side)
        {
            switch (rule)
            {
                case SpcRules.WERule1:
                    return new WERule1(side, limit);
                case SpcRules.WERule2:
                    return new WERule2(side, limit);
                case SpcRules.WERule3:
                    return new WERule3(side, limit);
                case SpcRules.WERule4:
                    return new WERule4(side, limit);
                case SpcRules.Trend:
                    return new Trend(side, limit);
                case SpcRules.Oscillation:
                    return new Oscillation(limit);
                case SpcRules.Stratification:
                    return new Stratification(limit);
                case SpcRules.Mixture:
                    return new Mixture(limit);
                default:
                    throw new SpcException(string.Format("Not support rule {0}", rule.ToString()));
            }
        }

    }
}
